home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 012 / sysreq.arc / SYSREQ.ASM next >
Encoding:
Assembly Source File  |  1980-01-01  |  4.2 KB  |  120 lines

  1. PAGE ,132
  2. ;******************************************************************************
  3. ;  SYSREQ    -  Turns the Sys-Req key on PC-AT's into a pause key.
  4. ;
  5. ;  Description    -  SYSREQ loads up an interrupt service routine to service
  6. ;           the interrupt that is generated when the Sys-Req key is
  7. ;           pressed on the PC-AT's keyboard  (interrupt 15H). The
  8. ;           first time the key is pressed the routine enters a
  9. ;           pause loop that is only exited when the key is pressed
  10. ;           a second time (i.e. press it once - pause; press it again -
  11. ;           continue).  The advantages to SYSREQ are 1) only one key
  12. ;           stroke to pause instead of two (Crtl-Num-Lock), and 2) it
  13. ;           doesn't need to filter all key stokes to determine when
  14. ;           the key is depressed, since the BIOS keyboard service
  15. ;           routine generates the interrupt when Sys-Req is pressed.
  16. ;           The disadvantage is that it only works on AT's.
  17. ;
  18. ;  Notes    -  The source code was written for assembly with
  19. ;           Microsoft's Marco-Assembler.
  20. ;
  21. ;  Date     -  17 May 1986
  22. ;
  23. ;  Author    -  David Oro
  24. ;******************************************************************************
  25. ;=======EQUATES
  26. CLEAR_F         EQU    000H    ;Value of cleared flag.
  27. SET_F            EQU    001H    ;Value of set flag.
  28. SYS_REQ_INT        EQU    015H    ;Interrupt vector for Sys-Req key.
  29. DOS_FUNCTION        EQU    021H    ;DOS Function request interrupt.
  30. DISPLAY_STRING        EQU    009H    ;DOS Display string function.
  31. GET_VECTOR        EQU    035H    ;DOS Get vector address function.
  32. SET_VECTOR        EQU    025H    ;DOS Set vector address function.
  33. TERMINATE_RESIDENT    EQU    027H    ;DOS Terminate but stay resident int.
  34. BIOS_DATA        EQU    00040H    ;Base segment of BIOS data area.
  35. CRT_MODE        EQU    00049H    ;Offset of CRT_MODE byte in BIOS data.
  36. CRT_MODE_SET        EQU    00065H    ;Offset of CRT_MODE_SET byte.
  37. CRT_CONTROL        EQU    003D8H    ;Address of crt control port.
  38.  
  39. ;=======CODE
  40. CSEG    SEGMENT PARA    PUBLIC    'CODE'
  41.     ORG    00100H
  42.     ASSUME    CS:CSEG,DS:CSEG
  43.  
  44. START:    JMP    SHORT INITIALIZE    ;Initialize variables.
  45.  
  46. OLD_INT  LABEL    DWORD            ;Space for old interrupt vector
  47. OLD_INT_IP    DW    ?        ;  Instruction pointer
  48. OLD_INT_CS    DW    ?        ;  Code segment
  49. PAUSE_ACTIVE    DB    CLEAR_F     ;Pause active flag
  50.  
  51. NEW_INT PROC   FAR            ;Interrupt service routine entry point.
  52.     ASSUME    DS:NOTHING
  53.  
  54.     STI                ;Turn interrupts back on.
  55.     CMP    AX, 08500H        ;Is Sys-Req key pushed down?
  56.     JE    SYS_REQ_MAKE        ; Yes: Service pause request.
  57.     CMP    AX, 08501H        ;Is Sys-Req key let up?
  58.     JE    EXIT_INT        ; Yes: Ignore it and exit.
  59.     JMP    CS:OLD_INT        ;If not Sys-Req key, do old interrupt.
  60.  
  61. SYS_REQ_MAKE:
  62.     CMP    CS:PAUSE_ACTIVE, SET_F    ;Is pause currently active?
  63.     JE    QUIT_PAUSE        ; Yes: Reset pause flag and exit.
  64.     MOV    CS:PAUSE_ACTIVE, SET_F    ; No: Set pause flag.
  65.     PUSH    DS            ;Save data segment
  66.     PUSH    BX            ;Save BX
  67.     MOV    AX, BIOS_DATA        ;Point to ...
  68.     MOV    DS, AX            ;     ... BIOS data area base.
  69.     MOV    BX, CRT_MODE        ;Point to current video mode.
  70.     MOV    AL, [BX]        ;Get current video mode.
  71.     CMP    AL, 007H        ;Is it monochrome?
  72.     JAE    MONO            ; Yes: Then don't worry about it
  73.     MOV    BX, CRT_MODE_SET    ; No: point to video mode setting...
  74.     MOV    AL, [BX]        ;     and get it...
  75.     PUSH    DX            ;     and save DX...
  76.     MOV    DX, CRT_CONTROL     ;     and point to video controller...
  77.     OUT    DX, AL            ;     and turn video on...
  78.     POP    DX            ;     and restore DX.
  79.  
  80. MONO:    POP    BX            ;Restore BX.
  81.     POP    DS            ;Restore data segment.
  82.  
  83. WAIT_LOOP:
  84.     CMP    CS:PAUSE_ACTIVE, SET_F    ;Is pause flag set?
  85.     JE    WAIT_LOOP        ; Yes: Loop until it is cleared.
  86.     IRET                ; No:  Return from interrupt.
  87.  
  88. QUIT_PAUSE:
  89.     MOV    CS:PAUSE_ACTIVE,CLEAR_F ;Clear pause flag.
  90. EXIT_INT:
  91.     IRET                ;Exit interrupt.
  92.  
  93. NEW_INT ENDP                ;End of interrupt service routine.
  94.  
  95. INITIALIZE:
  96.     ASSUME    DS:CSEG
  97.     MOV    AL, SYS_REQ_INT
  98.     MOV    AH, GET_VECTOR
  99.     INT    DOS_FUNCTION        ;Get old interrupt vector
  100.     MOV    OLD_INT_IP, BX        ;  save instruction pointer
  101.     MOV    OLD_INT_CS, ES        ;  save code segment
  102.  
  103.  
  104.     MOV    DX, OFFSET NEW_INT    ;New interrupt instruction pointer
  105.     MOV    AL, SYS_REQ_INT
  106.     MOV    AH, SET_VECTOR
  107.     INT    DOS_FUNCTION        ;Set new interrupt address
  108.  
  109.     MOV    DX, OFFSET MESSAGE    ;Output message...
  110.     MOV    AH, DISPLAY_STRING    ; to the standard...
  111.     INT    DOS_FUNCTION        ;  output device.
  112.  
  113.     MOV    DX, OFFSET INITIALIZE    ;End of ISR code
  114.     INT    TERMINATE_RESIDENT    ;Terminate but leave ISR resident.
  115.  
  116. MESSAGE DB    00DH,00AH,'Sys-Req key pause routine installed.',00DH,00AH,'$'
  117.  
  118. CSEG    ENDS
  119.     END    START
  120.